import CustOrderService from "@/api/order/CustOrderService";

const commonDetail = {
    //明细公用方法js
    data() {
        return {
        };
    },
    mounted() {
        this.verificationTime()
    },
    computed: {},
    methods: {
        async creatCustInfo(val, flag) {
            //手写客户名称创建客户公用方法
            if (flag && flag == 'input') {//判断是否有手输标识
                if (val.data == "") return;//为空不走创建客户接口
                this.$store.commit('orders/SET_CUST_INFO',true);
                let result = await CustOrderService.qryAZCustId({ custName: val.data });
                if (result.code == 200) {
                    this.$store.commit('orders/SET_CUST_INFO',false);
                    if (result.meta.resultCode == 0) {
                        this.formData[val.key].text = val.data;
                        this.formData[val.key].value = result.meta.custId;
                    } else {
                        this.formData[val.key].text = '';
                        this.formData[val.key].value = '';
                        this.$alert("创建甲乙端客户失败", "提示", { type: "warning" });
                    }
                }else {
                    this.$store.commit('orders/SET_CUST_INFO',false);
                }
            }
        },
        /**
         * add by wubin 2021-9-1
         * 需求:  审核前    的订单和需求单都需要做-要求完成时间不得小于当天的限制
         * 310（审核前）  311（审核后） 都是需求单 atterNmae:100012033
         * 312（审核前）  313（审核后） 都是订单   atterNmae:100010082
         */
        verificationTime(){
            let ppmCondition = JSON.parse(sessionStorage.getItem("ppmCondition"));
            if( ppmCondition.optionId == "310" || ppmCondition.optionId == "312"){
                for (let key in this.formData) {
                    if (key.split("-")[1] == "100012033" || key.split("-")[1] == "100010082") {
                        this.SetRequired({
                            attrName: "要求完成日期",
                            formkey: key,
                            reqName: "exceedTime",
                            reqStatus: true,
                        });
                    }
                }
            }
        }
    },

}

export default commonDetail;
